import os
import sys

import django
from order_platform.settings import CACHES

# 1. 伪造，让Django启动
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "order_platform.settings")
django.setup()

# 方式一
from django_redis import get_redis_connection
conn = get_redis_connection("default")
res=conn.get("xx")
print(res)
conn.set("xx", "123123")
res=conn.get("xx")
print(res)


# 方式二
from django.core.cache import cache

cache.set("xx", "456456")
res=conn.get("xx")
print(res)
